package com.lxh.observer;

import java.util.ArrayList;

/**
 * 通知者
 */
public class BanZhang implements Observable {

    private ArrayList<Observer> observers = new ArrayList<>();

    @Override
    public void add(Observer observer) {
        observers.add(observer);
    }

    @Override
    public void remove(Observer observer) {
        observers.remove(observer);
    }

    @Override
    public void notifyObserver(String context) {
        for (Observer observer : observers) {
            observer.update(context);
        }
    }

    public void sendNotify(String context) {
        System.out.println("班长发通知了：" + context);
        notifyObserver(context);
    }
}
